package com.example.demo.controller;

import com.example.demo.entity.FileMeta;
import com.example.demo.service.FileService;

import java.io.File;
import java.sql.SQLException;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-06-30
 * Time: 20:51
 */
public class SearchController {
    private FileController fileController; // Manager

    private FileService fileService; // DAO

    // 初始化数据库
    public void init(String basePath) throws SQLException {
        fileService.initDB();
        fileController.scanAll(new File(basePath));
        System.out.println("SearchController 初始化完成 ");
    }

    // 查找方法
    public List<FileMeta> search(String pattern) throws SQLException {
        return fileService.searchByPattern(pattern);
    }
}
